package cn.hg.jbsa.event;

import com.jfinal.aop.Inject;

import cn.hg.jbsa.admin.model.JbsaLogAction;
import cn.hg.jbsa.admin.service.JbsaLogActionService;
import io.jboot.components.event.JbootEvent;
import io.jboot.components.event.JbootEventListener;
import io.jboot.components.event.annotation.EventConfig;

/**
 * @author 胡高
 * @date 2022/04/26
 */
@EventConfig(action = {"actionLog"})
public class JbsaLogEventListener implements JbootEventListener {

    @Inject
    JbsaLogActionService logActionService;

    /* (non-Javadoc)
     * @see io.jboot.components.event.JbootEventListener#onEvent(io.jboot.components.event.JbootEvent)
     */
    @Override
    public void onEvent(JbootEvent event) {
        if (!(event.getData() instanceof JbsaLogAction)) {
            return;
        }

        this.logActionService.save((JbsaLogAction) event.getData());
    }

}
